/**
 * 
 */
package com.cp16.tss.form;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;

import com.cp16.tss.handler.UserLogInHandler;

/**
 * @author ADMIN
 * 
 */
public class UserLoginForm extends JFrame implements ActionListener {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private JLabel lblCheckForm;
	private JTextField txtUserName;
	private JPasswordField pwPassword;
	private JLabel lblWelcomLogInForm;
	private JLabel lblUserName;
	private JLabel lblPassword;
	private JButton btnLogIn;
	private JLabel lblSignUpFor;
	private JLabel lblForgotYourPassword;
	private JLabel lblUserNameCheck;
	private JLabel lblPasswordCheck;

	private void loadLookAndFeel() {
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (ClassNotFoundException ex) {
			Logger.getLogger(UserLoginForm.class.getName()).log(Level.SEVERE,
					null, ex);
		} catch (InstantiationException ex) {
			Logger.getLogger(UserLoginForm.class.getName()).log(Level.SEVERE,
					null, ex);
		} catch (IllegalAccessException ex) {
			Logger.getLogger(UserLoginForm.class.getName()).log(Level.SEVERE,
					null, ex);
		} catch (UnsupportedLookAndFeelException ex) {
			Logger.getLogger(UserLoginForm.class.getName()).log(Level.SEVERE,
					null, ex);
		}
	}

	public UserLoginForm() {
		loadLookAndFeel();
		initComponents();
	}

	public void initComponents() {

		setTitle("CustomerCare- created by Hoang Ngoc Giang");
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setLocation(150,70);
		setSize(980, 650);
		setResizable(false);
		contentPane = new JPanel();
		contentPane.setBackground(new Color(102, 102, 204));
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		lblWelcomLogInForm = new JLabel("Welcome to Customer Care");
		lblWelcomLogInForm.setForeground(new Color(255, 255, 255));
		lblWelcomLogInForm.setBounds(327, 55, 353, 40);
		contentPane.add(lblWelcomLogInForm);
		lblWelcomLogInForm.setFont(new Font("Arial Rounded MT Bold",Font.PLAIN, 25));

		lblCheckForm = new JLabel("");
		lblCheckForm.setForeground(Color.WHITE);
		lblCheckForm.setFont(new Font("Tahoma", Font.PLAIN, 20));
		lblCheckForm.setBounds(382, 137, 243, 40);
		contentPane.add(lblCheckForm);
		
		lblUserName = new JLabel("User name");
		lblUserName.setForeground(new Color(255, 255, 255));
		lblUserName.setBounds(287, 213, 75, 34);
		contentPane.add(lblUserName);
		lblUserName.setFont(new Font("Tahoma", Font.PLAIN, 15));

		lblPassword = new JLabel("Password");
		lblPassword.setForeground(new Color(255, 255, 255));
		lblPassword.setBounds(287, 245, 75, 34);
		contentPane.add(lblPassword);
		lblPassword.setFont(new Font("Tahoma", Font.PLAIN, 15));

		txtUserName = new JTextField();
		txtUserName.setFont(new Font("Tahoma", Font.PLAIN, 14));
		txtUserName.setColumns(10);
		txtUserName.setBounds(382, 213, 243, 34);
		contentPane.add(txtUserName);

		lblUserNameCheck = new JLabel("");
		lblUserNameCheck.setForeground(Color.WHITE);
		lblUserNameCheck.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblUserNameCheck.setBounds(617, 213, 168, 34);
		contentPane.add(lblUserNameCheck);

		pwPassword = new JPasswordField();
		pwPassword.setFont(new Font("Tahoma", Font.PLAIN, 14));
		pwPassword.setBounds(382, 246, 243, 36);
		contentPane.add(pwPassword);

		lblSignUpFor = new JLabel("Sign Up for Customer Care");
		lblSignUpFor.setForeground(Color.WHITE);
		lblSignUpFor.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblSignUpFor.setBounds(412, 379, 182, 34);
		contentPane.add(lblSignUpFor);

		lblForgotYourPassword = new JLabel("Forgot your password?");
		lblForgotYourPassword.setForeground(Color.WHITE);
		lblForgotYourPassword.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblForgotYourPassword.setBounds(425, 424, 156, 34);
		contentPane.add(lblForgotYourPassword);

		lblPasswordCheck = new JLabel("");
		lblPasswordCheck.setForeground(Color.WHITE);
		lblPasswordCheck.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblPasswordCheck.setBounds(617, 247, 168, 34);
		contentPane.add(lblPasswordCheck);

		btnLogIn = new JButton("Log In");
		btnLogIn.setFont(new Font("Tahoma", Font.PLAIN, 15));
		btnLogIn.setForeground(new Color(0, 0, 0));
		btnLogIn.setBackground(new Color(255, 255, 255));
		btnLogIn.setBounds(382, 293, 243, 34);
		btnLogIn.addActionListener(this);
		contentPane.add(btnLogIn);
	}

	/**
	 * @return the lblCheckForm
	 */
	public JLabel getLblCheckForm() {
		return lblCheckForm;
	}

	/**
	 * @param lblCheckForm the lblCheckForm to set
	 */
	public void setLblCheckForm(JLabel lblCheckForm) {
		this.lblCheckForm = lblCheckForm;
	}

	/**
	 * @return the txtUserName
	 */
	public JTextField getTxtUserName() {
		return txtUserName;
	}

	/**
	 * @param txtUserName
	 *            the txtUserName to set
	 */
	public void setTxtUserName(JTextField txtUserName) {
		this.txtUserName = txtUserName;
	}

	/**
	 * @return the pwPassword
	 */
	public JPasswordField getPwPassword() {
		return pwPassword;
	}

	/**
	 * @param pwPassword
	 *            the pwPassword to set
	 */
	public void setPwPassword(JPasswordField pwPassword) {
		this.pwPassword = pwPassword;
	}

	/**
	 * @return the lblWelcomLogInForm
	 */
	public JLabel getLblWelcomLogInForm() {
		return lblWelcomLogInForm;
	}

	/**
	 * @param lblWelcomLogInForm
	 *            the lblWelcomLogInForm to set
	 */
	public void setLblWelcomLogInForm(JLabel lblWelcomLogInForm) {
		this.lblWelcomLogInForm = lblWelcomLogInForm;
	}

	/**
	 * @return the lblUserName
	 */
	public JLabel getLblUserName() {
		return lblUserName;
	}

	/**
	 * @param lblUserName
	 *            the lblUserName to set
	 */
	public void setLblUserName(JLabel lblUserName) {
		this.lblUserName = lblUserName;
	}

	/**
	 * @return the lblPassword
	 */
	public JLabel getLblPassword() {
		return lblPassword;
	}

	/**
	 * @param lblPassword
	 *            the lblPassword to set
	 */
	public void setLblPassword(JLabel lblPassword) {
		this.lblPassword = lblPassword;
	}

	/**
	 * @return the btnLogIn
	 */
	public JButton getBtnLogIn() {
		return btnLogIn;
	}

	/**
	 * @param btnLogIn
	 *            the btnLogIn to set
	 */
	public void setBtnLogIn(JButton btnLogIn) {
		this.btnLogIn = btnLogIn;
	}

	/**
	 * @return the lblSignUpFor
	 */
	public JLabel getLblSignUpFor() {
		return lblSignUpFor;
	}

	/**
	 * @param lblSignUpFor
	 *            the lblSignUpFor to set
	 */
	public void setLblSignUpFor(JLabel lblSignUpFor) {
		this.lblSignUpFor = lblSignUpFor;
	}

	/**
	 * @return the lblForgotYourPassword
	 */
	public JLabel getLblForgotYourPassword() {
		return lblForgotYourPassword;
	}

	/**
	 * @param lblForgotYourPassword
	 *            the lblForgotYourPassword to set
	 */
	public void setLblForgotYourPassword(JLabel lblForgotYourPassword) {
		this.lblForgotYourPassword = lblForgotYourPassword;
	}

	/**
	 * @return the lblUserNameCheck
	 */
	public JLabel getLblUserNameCheck() {
		return lblUserNameCheck;
	}

	/**
	 * @param lblUserNameCheck
	 *            the lblUserNameCheck to set
	 */
	public void setLblUserNameCheck(JLabel lblUserNameCheck) {
		this.lblUserNameCheck = lblUserNameCheck;
	}

	/**
	 * @return the lblPasswordCheck
	 */
	public JLabel getLblPasswordCheck() {
		return lblPasswordCheck;
	}

	/**
	 * @param lblPasswordCheck
	 *            the lblPasswordCheck to set
	 */
	public void setLblPasswordCheck(JLabel lblPasswordCheck) {
		this.lblPasswordCheck = lblPasswordCheck;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		UserLogInHandler userLogInHandler = new UserLogInHandler();
		if (e.getSource() == btnLogIn) {
			userLogInHandler.signInLogInForm(this);
		}
	}

}
